package used

import auction.ParsedCar

class UsedCar {
	long websiteId
	BigDecimal price
	String title
	Long mileage
	String transmission
	String engine
	String fuel
	Integer year

	static constraints = {
		mileage nullable: true
		transmission nullable: true
		engine nullable: true
		fuel nullable: true
		year nullable: true
	}

	static mapping = {
        websiteId index:"website_id_index", unique: 'true', column: 'website_id'
    }

	static UsedCar createCar(ParsedCar parsedCar){
		return new UsedCar(websiteId: parsedCar.id,
							price: parsedCar.price,
							title: parsedCar.title,
							mileage: parsedCar.mileage,
							transmission: parsedCar.transmission,
							engine: parsedCar.engine,
							fuel: parsedCar.fuel,
							year: parsedCar.year)
	}
}
